package day0716;

import javax.swing.*;
import java.awt.*;

public class test2 {
    public static void main(String[] args) {
        JFrame jf=new JFrame();
        Mypane2 mypane=new Mypane2();
        jf.add(mypane);
        jf.setSize(480,800);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setVisible(true);
        jf.setLocationRelativeTo(null);
    }
}


class Mypane2 extends JPanel{
    public void paint(Graphics g) {
        //读取图的代码
        Image img=new ImageIcon("images/背景.jpg").getImage();
        g.drawImage(img, 0,0, null);
    }
}